package com.demo.mapsocial;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;

import android.annotation.TargetApi;
import android.app.ActionBar;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ShareActionProvider;

@TargetApi(14)
public class MainActivity extends MapActivity {
	
	private ActionBar actionBar;
	private MapView mapView;
	private ShareActionProvider shareAction;
	

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        // ActionBar configuration
        actionBar = getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        
        // MapView settings
        mapView = (MapView) findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);  
    }
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        
        shareAction = (ShareActionProvider) menu.findItem(R.id.menu_share).getActionProvider();
        shareAction.setShareIntent(getShareIntent());
        
        return true;
    }

	@Override
	protected boolean isRouteDisplayed() {
		// TODO Auto-generated method stub
		return false;
	}
	
	private Intent getShareIntent() {
		Intent sharingIntent = new Intent(Intent.ACTION_SEND);
		sharingIntent.setType("text/plain");

		sharingIntent.putExtra(Intent.EXTRA_SUBJECT,
				getString(R.string.main_share_subject));
		sharingIntent.putExtra(Intent.EXTRA_TITLE,
				getString(R.string.main_share_title));
		sharingIntent.putExtra(Intent.EXTRA_TEXT,
				getString(R.string.main_share_body));
		
		return sharingIntent;
	}
    
}
